﻿using System;
using UnityEngine;


public partial class PlayerController : MonoBehaviour
{


    public void HurtState(float hurtItemX)
    {
        isHitting = true;
        _playerHurtOnLeft = hurtItemX >= transform.position.x;

        Invoke(nameof(HurtStateFinish), 0.4f);
    }

    public void HurtStateFinish()
    {
        isHitting = false;

    }


    public void Death(float hurtItemX, float delay = 1)
    {
        HurtState(hurtItemX);

        if (delay <= 0)
        {
            DelayDeath();
        }
        else
        {
            Invoke(nameof(DelayDeath), delay);
        }
    }

    void DelayDeath()
    {
        isHitting = false;
        GameManager.Instance.Death();
        Destroy(gameObject);
    }
}
